package cn.wubo.task.order.statistics;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.generator.FastAutoGenerator;
import com.baomidou.mybatisplus.generator.config.OutputFile;
import com.baomidou.mybatisplus.generator.engine.FreemarkerTemplateEngine;

import java.util.Collections;

public class CodeGenerator {

    public static void main(String[] args) {
        FastAutoGenerator.create("jdbc:h2:file:./data/demo;AUTO_SERVER=TRUE", "sa", "")
                .globalConfig(builder -> {
                    builder.outputDir("src\\main\\java");
                })
                .packageConfig(builder ->
                        builder.parent("cn.wubo.task.order.statistics") // 设置父包名
                                .pathInfo(Collections.singletonMap(OutputFile.xml, "src\\main\\resources\\mapper")) // 设置mapperXml生成路径
                )
                .strategyConfig(builder ->
                        builder.addExclude("flyway_schema_history")
                                .controllerBuilder()
                                .serviceBuilder()
                                //.enableFileOverride()
                                .entityBuilder()
                                .enableLombok()
                                .enableFileOverride()
                                .idType(IdType.ASSIGN_ID)
                )
                .templateEngine(new FreemarkerTemplateEngine())
                .execute();
    }
}
